package com.netwit;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.ApplicationContext;

import java.util.Arrays;

@SpringBootApplication
@MapperScan(basePackages={"com.netwit.mapper"})
@ServletComponentScan
public class Application extends SpringBootServletInitializer {

    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }

    public static void main(String[] args) {
        ApplicationContext ctx = SpringApplication.run(Application.class, args);
        listBeans(ctx);
    }

    private static void listBeans(ApplicationContext ctx) {
        String[] names = ctx.getBeanDefinitionNames();
        Arrays.asList(names).stream().filter(name -> name.startsWith("APP")).forEach(System.out::println);
    }
}
